' Add Until Marker
' This program reads and adds values stored in DATA statements
'   until it detects an end-of-data marker (-9999).

CLS

WHILE (number! <> -9999)     ' loop until end-of-data marker is read
    READ number!                          ' assign the next DATA item to number!
    IF (number! <> -9999) THEN     ' if not end-of-data marker, then
        sum! = sum! + number!           '   keep a running total
        items% = items% + 1             '   count the number of values read
    END IF
WEND

PRINT "The sum of the"; items%; "numbers is"; sum!
PRINT
INPUT "Press Return to continue", dummy$

DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
DATA 88.2, 25, 3.3, 100, -74.2, 0, 20, 0.34, -89, 5.4567
DATA -9999
